package com.angel.service.ServiceImpl;

import com.angel.bean.dto.ProblemsDto;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import com.angel.bean.Problems;
import com.angel.mapper.ProblemsDao;
import com.angel.service.ProblemsService;

@Service
public class ProblemsServiceImpl implements ProblemsService {

    @Resource
    private ProblemsDao problemsDao;

    @Override
    public int insert(Problems problems) {
        return problemsDao.insert(problems);
    }

    @Override
    public int insertSelective(Problems problems) {
        return problemsDao.insertSelective(problems);
    }

    @Override
    public int insertList(List<Problems> problemss) {
        return problemsDao.insertList(problemss);
    }

    @Override
    public int update(Problems problems) {
        return problemsDao.update(problems);
    }

    @Override
    public List<Problems> selectAll(Problems problems) {
        return problemsDao.selectAll(problems);
    }

    @Override
    public Problems getOne(Problems problems) {
        List<Problems> problemss = problemsDao.selectAll(problems);
        if (problemss == null || problemss.isEmpty()) {
            return null;
        }
        return problemss.get(0);

    }

    @Override
    public List<ProblemsDto> selectAllHasName(Problems problems) {
        return problemsDao.selectAllHasName(problems);
    }

    @Override
    public ProblemsDto getOneHasName(Problems problems) {
        List<ProblemsDto> problemss = problemsDao.selectAllHasName(problems);
        if (problemss == null || problemss.isEmpty()) {
            return null;
        }
        return problemss.get(0);
    }
}
